#!/usr/bin/env python
# coding=utf-8

import time
import hello_pb2 as hello

_SECONDS_PER_DAY = 60 * 60 * 24

class Greeter(hello.BetaGreeterServicer):

    def sayHello(self, req, context):
        return hello.HelloRsp(msg = 'Hello, %s!' % req.name)


def server():
    server = hello.beta_create_Greeter_server(Greeter())
    server.add_insecure_port('[::]:50051')
    server.start()
    try:
        while True:
            time.sleep(_SECONDS_PER_DAY)
    except KeyboardInterrupt:
        server.stop()

if __name__ == '__main__':
    server()
